package service;

import dao.UserDao;

import java.util.Scanner;

/**
 * @Description TODO
 * @Author hhy
 * @Date 2020/9/17 11:10
 */
public class RegisteredService {
    public void register(){
        System.out.println("******欢迎来到注册界面*******");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的用户名");
        String username = sc.next();
        if (UserDao.isuserRegistered(username)){
            System.out.println("用户已存在，请重新输入");
            register();
        }
        System.out.println("请输入你的密码");
        String password = sc.next();
        System.out.println("请重新输入你的密码");
        String pssswordAgain = sc.next();
        if (password.equals(pssswordAgain)){  //如果是密码正确的话，那就添加
            new UserDao().addUser(username,password);
            new LoginService().login();
            return;
        }
        System.out.println("两次输入密码不正确哦~请重新输入");
        register();
    }
}
